package sk.marek.barak.server;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import sk.marek.barak.client.LoginInfo;

public class LoginInfoGAEDAO implements LoginInfoDAO {

	@Override
	public LoginInfo login(String requestUrl) {
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		LoginInfo loginInfo = new LoginInfo();

		
		if(user==null){
			loginInfo.setLogedIn(false);
			loginInfo.setLoginUrl(userService.createLoginURL(requestUrl));
		}else{
			loginInfo.setLogedIn(true);
			loginInfo.setLogoutUrl(userService.createLogoutURL(requestUrl));
			
		}
		return loginInfo;
	}
	

}
